﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TestSqlite.Sqlite3
{
    [TestClass]
    public class TestWithoutKeyEnity
    {
        [TestMethod]
        public void InsertWithoutKeyEntityTest()
        {
            WithoutKeyEntity t1 = new WithoutKeyEntity();

            t1.Field1 = 1;
            t1.Field2 = 2;
            t1.Field3 = 3;

            int rowcount = WithoutKeyEntity.GetAllEntities().Count;

            t1.Save();

            Assert.AreEqual(rowcount + 1, WithoutKeyEntity.GetAllEntities().Count);

            WithoutKeyEntity.Delete(1, 2, 3);
            Assert.AreEqual(rowcount, WithoutKeyEntity.GetAllEntities().Count);

        }

        [TestMethod]
        public void SearchWithoutKeyEntityTest()
        {
            WithoutKeyEntity t1 = new WithoutKeyEntity();

            t1.Field1 = 1;
            t1.Field2 = 2;
            t1.Field3 = 3;

            t1.Save();
            int rowcount = WithoutKeyEntity.SearchEntities("where Field1={0} and Field2={1} and Field3={2}", 1, 2, 3).Count;

            Assert.AreEqual(true, rowcount > 0);

            WithoutKeyEntity.Delete(1, 2, 3);
            int rowcount2 = WithoutKeyEntity.SearchEntities("where Field1={0} and Field2={1} and Field3={2}", 1, 2, 3).Count;
            Assert.AreEqual(rowcount - 1, rowcount2);
        }
    }
}
